package cn.com.yusys.yusp.admin.web.rest;

import cn.com.yusys.yusp.admin.service.AnnouncementManagementService;
import cn.com.yusys.yusp.admin.service.DashBoardService;
import cn.com.yusys.yusp.commons.mapper.QueryModel;
import cn.com.yusys.yusp.commons.web.rest.dto.ResultDto;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/dashBoard")
public class DashBoardResource {

    @Resource
    private DashBoardService dashBoardService;


    @GetMapping("/getPublishedBoard")
    public ResultDto<List<Map<String, Object>>> getPublishedBoard(QueryModel queryModel) {
        List<Map<String, Object>> list = dashBoardService.getPublishedBoard(queryModel);
        return new ResultDto<>(list);
    }

    @PostMapping("/updateReadFlg")
    public ResultDto<Integer> updateReadFlg(@RequestBody Map map) {
        String readFlg =map.get("readFlg").toString();
        if (readFlg.equals("0")){
            return new ResultDto<>(dashBoardService.updateReadFlg(map));
        }
        else {
            return new ResultDto<>(null);
        }
    }

    @GetMapping("/getCustomerBirthday")
    public ResultDto<List<Map<String, Object>>> getCustomerBirthday(QueryModel queryModel) {
        List<Map<String, Object>> list = dashBoardService.getCustomerBirthday(queryModel);
        return new ResultDto<>(list);
    }

    @GetMapping("/getOverdueReminder")
    public ResultDto<List<Map<String, Object>>> getOverdueReminder(QueryModel queryModel) {
        List<Map<String, Object>> list = dashBoardService.getOverdueReminder(queryModel);
        return new ResultDto<>(list);
    }

    @GetMapping("/getLargeMovingAccount")
    public ResultDto<List<Map<String, Object>>> getLargeMovingAccount(QueryModel queryModel) {
        List<Map<String, Object>> list = dashBoardService.getLargeMovingAccount(queryModel);
        return new ResultDto<>(list);
    }

    @GetMapping("/getImportantCust")
    public ResultDto<List<Map<String, Object>>> getImportantCust(QueryModel queryModel) {
        List<Map<String, Object>> list = dashBoardService.getImportantCust(queryModel);
        return new ResultDto<>(list);
    }

    @GetMapping("/getWealthReminder")
    public ResultDto<List<Map<String, Object>>> getWealthReminder(QueryModel queryModel) {
        List<Map<String, Object>> list = dashBoardService.getWealthReminder(queryModel);
        return new ResultDto<>(list);
    }

    @GetMapping("/getWithdrawalInAdvance")
    public ResultDto<List<Map<String, Object>>> getWithdrawalInAdvance(QueryModel queryModel) {
        List<Map<String, Object>> list = dashBoardService.getWithdrawalInAdvance(queryModel);
        return new ResultDto<>(list);
    }

    @GetMapping("/getProductExpiration")
    public ResultDto<List<Map<String, Object>>> getProductExpiration(QueryModel queryModel) {
        List<Map<String, Object>> list = dashBoardService.getProductExpiration(queryModel);
        return new ResultDto<>(list);
    }

    @GetMapping("/getRepaymentReminder")
    public ResultDto<List<Map<String, Object>>> getRepaymentReminder(QueryModel queryModel) {
        List<Map<String, Object>> list = dashBoardService.getRepaymentReminder(queryModel);
        return new ResultDto<>(list);
    }

    @GetMapping("/getRemindInfo")
    public ResultDto<Map<String, Object>> getRemindInfo(QueryModel queryModel) {
        Map<String, Object> map = dashBoardService.getRemindInfo(queryModel);
        return new ResultDto<>(map);
    }

    @GetMapping("/getCustAssetDistr")
    public ResultDto<List<Map<String, Object>>> getCustAssetDistr(QueryModel queryModel) {
        CustCenterResource.judgeUserJurisdiction(queryModel, true);
        List<Map<String, Object>> list = dashBoardService.getCustAssetDistr(queryModel);
        return new ResultDto<>(list);
    }

    @GetMapping("/getCustAssetDistrDetail")
    public ResultDto<List<Map<String, Object>>> getCustAssetDistrDetail(QueryModel queryModel) {
        CustCenterResource.judgeUserJurisdiction(queryModel, true);
        List<Map<String, Object>> list = dashBoardService.getCustAssetDistrDetail(queryModel);
        return new ResultDto<>(list);
    }

    @GetMapping("/getPublishedNotice")
    public ResultDto<List<Map<String, Object>>> getPublishedNotice(QueryModel queryModel) {
//        CustCenterResource.judgeUserJurisdiction(queryModel, true);
        List<Map<String, Object>> list = dashBoardService.getPublishedNotice(queryModel);
        return new ResultDto<>(list);
    }

    @GetMapping("/getGridMainData")
    public ResultDto<List<Map<String, Object>>> getGridMainData(QueryModel queryModel) {
        CustCenterResource.judgeUserJurisdiction(queryModel, false);
        List<Map<String, Object>> list = dashBoardService.getGridMainData(queryModel);
        return new ResultDto<>(list);
    }

    @GetMapping("/getEachGridData")
    public ResultDto<List<Map<String, Object>>> getEachGridData(QueryModel queryModel) {
        CustCenterResource.judgeUserJurisdiction(queryModel, false);
        List<Map<String, Object>> list = dashBoardService.getEachGridData(queryModel);
        return new ResultDto<>(list);
    }

    @GetMapping("/getRedBlackList")
    public ResultDto<List<Map<String, Object>>> getRedBlackList(QueryModel queryModel) {
        CustCenterResource.judgeUserJurisdiction(queryModel, false);
        List<Map<String, Object>> list = dashBoardService.getRedBlackList(queryModel);
        return new ResultDto<>(list);
    }




}
